<?php /* Smarty version 2.6.20, created on 2013-05-25 01:50:46
         compiled from _core/_include/module/_mvc/control/tablerows/handletablerowproduceother.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'escape', '_core/_include/module/_mvc/control/tablerows/handletablerowproduceother.tpl', 53, false),)), $this); ?>
function HandleTableRowProduceOther(gui, item, options) {
  this._gui = gui;
  this._item = item;
  this._options = options;
  this._popupBox = new PopupBox();
  this._popupBox2 = new PopupBox2();
  
  this._parent = (options && options.parent) ? options.parent : null;
  this._user = (options && options.user) ? options.user : null;
  this._date = (options && options.date) ? options.date : null;
  this._callbackFunc = (options && options.callbackFunc) ? options.callbackFunc : function() {};
  
  this._createElements();
};

HandleTableRowProduceOther.prototype._createElements = function() {
  var gui, _self = this;
  DlmanageUtils.clear(this._gui);
  
  this._gui.name.appendChild(document.createTextNode(this._item.title));
  
  if (this._item.cancelled == 0) {
    var note = document.createElement('img');
    note.src = (this._item.v2_notes.length != 0) ? 'images/buttons/note_hilight.png' : 'images/buttons/note.png';
    note.style.cursor = 'pointer';
    note.style.margin = '0 0 0 5px';
    note._produce = this._item;
    note.onclick = function() { var div, pos, func1, func2;
                                var pro = this._produce;
                                div = document.createElement('div');
                                pos = DOMUtils.findPos(this);
                                MiscUtils.dialog(_self._popupBox2, pos, div, null, null, {t: pro.title, width: 760, height: 100});
                                new DialogProduceNote(div, pro, { author: _self._user, now: _self._date, popupBox: _self._popupBox2, callbackFunc: function() { _self._callbackFunc();} });
                                return false;
                              };
    this._gui.name.appendChild(note);
  }
  
  
  if (this._item.state != 2 && (this._item.pi_model == Constant.MODEL_NAME_PRECON)) {
  
    var args = '&oid=' + this._item.customerId +'&orid=' + this._item.orderId; 
    new RequestUtils()._mysql('cuspayment', args, function(result, params) { _self._emailtmp = (result.data.length == 1) ? result.data[0] : null;}, {php:'customphp/mysqlread.php'});   
      						    
      						    var a = document.createElement('a');
						        a.href = '#';
						        a.appendChild(document.createTextNode('Re-email Precon'));
						        a._im = this._item;
						        a.onclick = function() { 
                                      var pos = DOMUtils.findPos(this);
                                      var pay1 = [];
                                      
                                      //var _default ='<?php echo ((is_array($_tmp=@precontemp)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
';
                                      
                                      var _default = _self._emailtmp;
                                                        
                                      var div = document.createElement('div');
                                      var div2 = document.createElement('div');
                                      
                                       
                                      div2.style.marginTop = '5px';
                                      
                                      var input = document.createElement('input');
                                      input.type='text';
                                      input.style.width = '345px';
                                      input.style.height = '30px';
                                      input.value ='Precon for Customer '+ this._im.customerId;
                                  
                                      div2.appendChild(document.createTextNode('Subject '));
                                      div2.appendChild(input);
                                      div.appendChild(div2);
                                                        
                                      var _im=this._im;
                                      var func1 = function() { 
                                              
                                          if (input.value == '') {
                                              window.alert('Subject is not null!');
                                              return;
                                            }
                                                        var rpt = {};
                                                        rpt.id = _im.customerId;
                                                        rpt.createDate = _self._date;
                                                        rpt.account = _self._user;
                                                        rpt.bodytext = pay1._text;
                                                        rpt.subject = input.value;                                          
                                                        rpt.orderid = _im.orderId;
                                                        
                                          new RequestUtils()._mwrite('preconemail', [rpt], [], _self._callbackFunc, { pos: DOMUtils.findPos(this) });
                                          _self._popupBox2._close();
                                        };                                                                                            
                                                                                                    
                                        var func2 = function() { _self._popupBox2._close();};
                                        MiscUtils.dialog(_self._popupBox2, pos, div, func1, func2, {t: 'Re-email Precon',ok:'ok',cancel:'cancel'});
                                        new DialogInput(div, pay1, { title: '',default:_default});
						               };
						               
						        this._gui.name.appendChild(a);
  }
  
  //console.log(this._item);
  if (this._item.how && (this._item.pi_model == Constant.MODEL_NAME_MUSIC || this._item.pi_model == Constant.MODEL_NAME_REQUIREMENT)) {
    this._gui.info.appendChild(document.createTextNode(this._item.how));
    if ( this._parent.disposalstatus == 0 && this._item.cancelled == 0) {
      a = document.createElement('a');
      a.style.fontSize = '10px';
      a.href = '#';
      a.appendChild(document.createTextNode('Chg'));
      a.onclick = function() { var pos = DOMUtils.findPos(this);
                               var div = document.createElement('div');
                               var track = DlmanageUtils.getTrack(_self._item, _self._user, _self._date, null, '');
                               var func1 = function() { if (_self._item._method == '') {
                                                          window.alert('CAN NOT BE EMPTY');
                                                          return;
                                                        }
                                                        _self._popupBox._close();
                                                        
                                                        if (track) {
                                                          if (track.how == _self._item._method) {
                                                            _self._callbackFunc();
                                                            return;
                                                          }
                                                        }
                                                        var e = ProduceEvent.instance();
                                                        e.produce_trackId = _self._item.trackId;
                                                        e.date = _self._date;
                                                        e.userAccount = _self._user.account;
                                                        e.extra = 'ALTER TO ' + _self._item._method + ' (' + _self._item.how + ')';
                                                        
                                                        track.extra = 'ALTER TO ' + _self._item._method + ' (' + _self._item.how + ')';
                                                        
                                                        _self._item.how = _self._item._method;
                                                        new RequestUtils()._write2([{ n: 'produce', a: [_self._item], r: [] }, { n: 'produceevent', a: [e], r: [] }, { n: 'producetrack', a: [track], r: []}], _self._callbackFunc, { php: Constant.FACTORY + '/customphp/mysqlwrite2.php', pos: pos });
                                                      };
                               var func2 = function() { _self._popupBox._close();
                                                        _self._callbackFunc();
                                                      };
                               MiscUtils.dialog(_self._popupBox, pos, div, func1, func2);
                               new DialogMethod(div, _self._item, null);
                               return false;
                             };
      this._gui.info.appendChild(a);
    }
  } else if (this._item.when && this._item.pUsers.length != 0 && (this._item.pi_model == Constant.MODEL_NAME_PRECON)) {
    var user = '';
    for (var i = 0, il = this._item.pUsers.length; i < il; i++) {
      var u = this._item.pUsers[i];
      if (u.trackId == '') {
        continue;
      }
      user += u.account;
      if (i < this._item.pUsers.length - 1) {
        user += ',';
      }
    }
    var str = SimpleDate.format(this._item.when, true).substring(0, 11) + ' ' + user;
    this._gui.info.appendChild(document.createTextNode(((str.length > 17) ? str.substring(0, 17) + '..' : str)));
    
    if (this._parent.disposalstatus == 0 && this._item.cancelled == 0) {
      a = document.createElement('a');
      a.style.fontSize = '10px';
      a.href = '#';
      a.appendChild(document.createTextNode('Chg'));
      a.onclick = function() { var pos = DOMUtils.findPos(this), date = _self._item.when;
                               var div = document.createElement('div');
                               produceUsers = DlmanageUtils.renew(_self._item.pUsers);
                               var track = DlmanageUtils.getTrack(_self._item, _self._user, _self._date, null, '');
                               var trackUser = DlmanageUtils.getTrackUser(_self._item, track);
                               var func1 = function() { if (produceUsers.length == 0 || !_self._item.when) {
                                                          window.alert('选择一个工作人员和一个时间');
                                                          return;
                                                        }
                                                        
                                                        if (_self._item.when.hours == 0 && _self._item.when.minutes == 0 ) {
                                                          var r = window.confirm('Hours & Minutes is  (00:00), CONTINUE?');
                                                          if (r) {
                                                            _self._popupBox._close();
                                                            
                                                            var e = ProduceEvent.instance();
                                                            e.produce_trackId = _self._item.trackId;
                                                            e.date = _self._date;
                                                            e.userAccount = _self._user.account;
                                                            var name = '';
                                                            for (var i = 0, il = produceUsers.length; i < il; i++) {
                                                              var u = produceUsers[i];
                                                              if (u.trackId == '') {
                                                                continue;
                                                              }
                                                              name += u.account;
                                                              if (i < produceUsers.length - 1) {
                                                                name += ',';
                                                              }
                                                            }
                                                            var tname = '';
                                                            for (var i = 0, il = trackUsers.length; i < il; i++) {
                                                              var t = trackUsers[i];
                                                              if (t.trackId == '') {
                                                                continue;
                                                              }
                                                              tname += t.account;
                                                              if (i < trackUsers.length - 1) {
                                                                tname += ',';
                                                              }
                                                            }
                                                            e.extra = 'ALTER TO ' + SimpleDate.format(_self._item.when, true) + ' ' + name + ' (' + SimpleDate.format(date, true) + ' ' + tname + ')';
                                                            track.extra = 'ALTER TO ' + SimpleDate.format(_self._item.when, true) + ' ' + name + ' (' + SimpleDate.format(date, true) + ' ' + tname + ')';
                                                            new RequestUtils()._write2([{ n: 'produce', a: [_self._item], r: [] }, { n: 'produceevent', a: [e], r: [] }, { n: 'producetrack', a: [track], r: []}, { n: 'produceuser', a: produceUsers, r: _self._item.pUsers}, { n: 'producetrackuser', a: trackUsers, r: track.pUsers} ], _self._callbackFunc, { php: Constant.FACTORY + '/customphp/mysqlwrite2.php', pos: pos });
                                                          }
                                                        } else {
                                                          _self._popupBox._close();
                                                          
                                                          var e = ProduceEvent.instance();
                                                          e.produce_trackId = _self._item.trackId;
                                                          e.date = _self._date;
                                                          e.userAccount = _self._user.account;
                                                          var name = '';
                                                          for (var i = 0, il = produceUsers.length; i < il; i++) {
                                                            var u = produceUsers[i];
                                                            if (u.trackId == '') {
                                                              continue;
                                                            }
                                                            name += u.account;
                                                            if (i < produceUsers.length - 1) {
                                                              name += ',';
                                                            }
                                                          }
                                                          var tname = '';
                                                          for (var i = 0, il = trackUsers.length; i < il; i++) {
                                                            var t = trackUsers[i];
                                                            if (t.trackId == '') {
                                                              continue;
                                                            }
                                                            tname += t.account;
                                                            if (i < trackUsers.length - 1) {
                                                              tname += ',';
                                                            }
                                                          }
                                                          e.extra = 'ALTER TO ' + SimpleDate.format(_self._item.when, true) + ' ' + name + ' (' + SimpleDate.format(date, true) + ' ' + tname + ')';
                                                          track.extra = 'ALTER TO ' + SimpleDate.format(_self._item.when, true) + ' ' + name + ' (' + SimpleDate.format(date, true) + ' ' + tname + ')';
                                                          new RequestUtils()._write2([{ n: 'produce', a: [_self._item], r: [] }, { n: 'produceevent', a: [e], r: [] }, { n: 'producetrack', a: [track], r: []}, { n: 'produceuser', a: produceUsers, r: _self._item.pUsers}, { n: 'producetrackuser', a: trackUsers, r: track.pUsers} ], _self._callbackFunc, { php: Constant.FACTORY + '/customphp/mysqlwrite2.php', pos: pos });
                                                        }
                                                      };
                               var func2 = function() { _self._popupBox._close();
                                                        _self._callbackFunc();
                                                      };
                               MiscUtils.dialog(_self._popupBox, pos, div, func1, func2);
                               new DialogAssignee(div, _self._item, { condition: '(d.pEnabled = 1 OR d.vEnabled = 1) and d.isdisplay = 0', date: true, preconUsers: produceUsers });
                               return false;
                             };
      this._gui.info.appendChild(a);
    }
  }
  
  gui = GuiProduce.instance(this._gui.task, this._gui.dateline, this._gui.progress);
  new HandleProduce(gui, this._item, this._options);
};